package com.sunnypower.rushfitapp.Noticepart;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sunnypower.rushfitapp.R;
import com.sunnypower.rushfitapp.entity.Notice;
import com.sunnypower.rushfitapp.entity.VReservecourse;

import java.util.List;


public class NoticeListAdapter extends BaseAdapter {

    private List<Notice> mList;
    private Context mContext;
    private LayoutInflater mLayoutInflater;


    public NoticeListAdapter(Context context, List<Notice> list) {
        mContext = context;
        mList = list;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.notice_list_item, null);
            viewHolder.notice_title = convertView.findViewById(R.id.notice_title);
            viewHolder.notice_title.setSelected(true);
            viewHolder.notice_cont = convertView.findViewById(R.id.notice_cont);
            viewHolder.notice_cont.setSelected(true);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Notice bean = mList.get(position);
        viewHolder.notice_title.setText(bean.getTitle());
        viewHolder.notice_cont.setText(bean.getContext());
        return convertView;
    }

    private static class ViewHolder {
        public TextView notice_title;
        public TextView notice_cont;
    }
}
